package me.zhengjie.gas.repositories;

import me.zhengjie.gas.dto.CardBindDto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CardBindRepository extends JpaRepository<CardBindDto, Integer> {
    @Query(value = "select * from {h-schema}card_bind where dept_id in (:deptIds)", nativeQuery = true)
    List<CardBindDto> findByDeptIds(@Param("deptIds") List<Long> deptIds);

    @Query(value = "select * from {h-schema}card_bind " +
            "where dept_id in (:deptIds) and car_license_no = :licenseNo limit 1", nativeQuery = true)
    CardBindDto findByLicenseNo(@Param("deptIds") List<Long> deptIds, @Param("licenseNo") String licenseNo);
}
